package cac.fenjian.resource.system.service;

import cac.fenjian.resource.system.dao.SystemRoadDao;
import com.cac.dme.adapter.rest.msg.ResponseMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.util.HashMap;
import java.util.List;

@Service
public class SystemRoadService {
    @Autowired
    private SystemRoadDao systemRoadDao;

    public List<HashMap> queryRoad(){
        return systemRoadDao.queryRoad();
    }

    @Transactional
    public ResponseMsg updateRoadStatus(HashMap map){
        try{
            systemRoadDao.updateRoadStatus(map);
            return new ResponseMsg().setMessage("操作成功").setRetCode("200");
        }catch (Exception e){
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return new ResponseMsg().setMessage("操作失败").setRetCode("201");
        }
    }
}
